import React, {PureComponent, useState} from 'react'
import  {useParams, useLocation, useNavigate, Navigate } from 'react-router-dom'

export default function Profile() {
  const [isLogin, setIsLogin] = useState(true)
  let params = useParams();
  console.log(params);
  
  console.log(params.id);

  return (
    isLogin ? <div>我的 {params.id}</div> : <Navigate to="/login" replace={true}/>
  )
}


// class Profile extends PureComponent {
//   render() {
//     return (
//       <div>我的 {this.props.match.params.id}</div>
//     )
//   }
// }

// function withRouter( Child ) {
//   return ( props ) => {
//     const location = useLocation();
//     const navigate = useNavigate();
//     const params = useParams();
//     return <Child { ...props } match={{params}} navigate={ navigate } location={ location } />
//   }
// }

// export default withRouter(Profile)